#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

vector<int> used;
vector< vector<int> > portals;

void dfs(int k)
{
	used[k] = 1;
	for (int j = 0; j < portals[k].size(); ++j)
	{
		int v = portals[k][j];
		if (used[v] == 0)
			dfs(v);
	}
}

int main()
{
	int n, m;
	cin >> n >> m;
	portals.resize(n);

	for (int i = 0; i < m; ++i)
	{
		int a, b;
		cin >> a >> b;
		portals[a - 1].push_back(b - 1);
	}
		
	bool good = true;
	for (int i = 0; i < n; ++i)
	{
		used.assign(n, 0);
		dfs(i);
		int count = accumulate(used.begin(), used.end(), 0);
		//cout << i << " " << count << endl;
		if (count != n)
		{
			good = false;
			break;
		}
	}

	if (good)
		cout << "OK";
	else
		cout << "FAIL";
}